# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Maintainer: Robin Candau <antiz@archlinux.org>
# Contributor: Frederik “Freso” S. Olesen <freso.dk@gmail.com>

pkgname=lutris
pkgver=0.5.14
pkgrel=1
pkgdesc='Open Gaming Platform'
arch=(any)
url=https://lutris.net
license=(GPL3)
depends=(
  cabextract
  curl
  gdk-pixbuf2
  glib2
  gnome-desktop
  gobject-introspection-runtime
  gtk3
  hicolor-icon-theme
  mesa-utils
  p7zip
  pango
  psmisc
  python
  python-cairo
  python-certifi
  python-dbus
  python-distro
  python-evdev
  python-gobject
  python-lxml
  python-moddb
  python-pillow
  python-requests
  python-urllib3
  python-yaml
  unzip
  webkit2gtk-4.1
  xdg-desktop-portal-impl
  xorg-xrandr
)
makedepends=(
  git
  meson
  ninja
  python-poetry-core
)
checkdepends=(
  python-nose-cover3
  wine
  xorg-server-xvfb
  xterm
  fluidsynth
  vulkan-tools
  pciutils
)
optdepends=(
  'gamemode: Allows games to request a temporary set of optimisations'
  'gvfs: GVFS backend'
  'innoextract: Extract Inno Setup installers'
  'lib32-gamemode: Allows games to request a temporary set of optimisations'
  'lib32-vkd3d: DirectX 12 support'
  'lib32-vulkan-icd-loader: Vulkan support'
  'python-protobuf: Battle.net support'
  'vkd3d: DirectX 12 support'
  'vulkan-icd-loader: Vulkan support'
  'vulkan-tools: Vulkan support'
  'wine: Windows support'
  'xorg-xgamma: Restore gamma on game exit'
)
_tag=ba9c0aea5a9db54dca2bc39dc7e9bad5c6a566b5
source=(git+https://github.com/lutris/lutris.git#tag=${_tag}
        fix-scummvm-tests.patch::https://github.com/lutris/lutris/commit/7efc304f595a9547bb4f01a823250d95b7722506.patch)
b2sums=('SKIP'
        'ace0ada78a15e6b1f0540f6a9da83d272eb3810761ada8a0ed77b92cf86da1730e5d51aef9234e3103751aa48bb262fe3812c033cd68e483050459ce98bdcf20')

pkgver() {
  cd lutris
  git describe --tags | sed 's/^v//'
}

prepare() {
  cd lutris

  # The scummvm tests would fail on a system where scummvm is not available, because https://github.com/K900/lutris/blob/7efc304f595a9547bb4f01a823250d95b7722506/lutris/runners/scummvm.py#L487 attempted to access an element from an empty list. Fix that by propagating the empty list, and use mocks to ensure we test both cases.
  # https://github.com/lutris/lutris/pull/5086
  patch -Np1 <${srcdir}/fix-scummvm-tests.patch
}

build() {
  arch-meson lutris build
  ninja -C build
}

check() {
  cd lutris
  xvfb-run nosetests --cover-erase --with-xunit --xunit-file=nosetests.xml --with-coverage --cover-package=lutris --cover-xml-file=coverage.xml
}

package() {
  DESTDIR="${pkgdir}" meson install -C build
}

# vim: ts=2 sw=2 et:
